<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/wesite/view/common/base.jsp"%>
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>重置密码</title>
    <%@ include file="/wesite/view/common/common.jsp"%>
    <style type="text/css">
        html,body{background:#fff;}
        .loginbox.signbox{
            margin:0;
        }

    </style>
</head>
<body>
<input type="hidden" name="id" value="${id}">
<div class="loginbox signbox">
    <div class="login-input">
        <div class="input-text"><span class="text-tit">用户名</span><input id="phone" name="phone" type="number" value="${phone}" readonly="true" placeholder="手机号"></div>
        <div class="input-text"><span class="text-tit">用户名</span><input class="code" name="smscode" type="number" placeholder="验证码">
            <span class="send"><a href="javascript:tosensms();" id="smsbtn" class="yzm-btn">获取验证码</a></span>
        </div>
        <div class="itemTip" id="itemTip_old"></div>
        <div class="input-text"><span class="text-tit">用户名</span><input type="password" name="newpwd" placeholder="密码"></div>
        <div class="itemPassWord" id="codetip"></div>

    </div>
    <input type="button" value="完成" onclick="next2()">
</div>
</body>
</html>
<script src="${webctx}/script/sms.js"></script>
<script src="${webctx}/script/common.js"></script>
<script type="text/javascript">
    var user;
    function tosensms() {
        var dataphone = ($("[name='phone']").val());
        $w.httpRequest({
            url:"${ctx}/we/user/sendsms",
            data:{"mobile":$("[name='phone']").val()},

            ok:function(ret){
                sendsms(dataphone,'findpwd','smsbtn');
            }
        })

    }
    function next2() {
        var dataphone = ($("[name='phone']").val());
        var id = $("[name='id']").val();
        var toast = new auiToast({})
        $w.httpRequest({
            url:"${ctx}/we/user/checksmscode",
            data:{"mobile":dataphone,"smscode":$("[name='smscode']").val()},
            ok:function(ret){
                if(ret.Data=='true'){
                    if ($("[name='newpwd']").val().length<6){
                        toast.fail({
                            title : "请输入6位密码",
                            duration : 1000
                        })

                        return;
                    }
                    if ($("[name='newpwd']").val().length>16){
                        toast.fail({
                            title : "密码不能超过16位数",
                            duration : 1000
                        })
                        return;
                    }
                    $w.httpRequest({
                        url:"${ctx}/we/user/findpwd",
                        data:{"userid":id,"phone":dataphone,"smscode":$("[name='smscode']").val(),"newpwd":$("[name='newpwd']").val()},
                        ok:function(ret){
                            window.location.href="${ctx}/we/user/login";
                        }
                    })
                }else toast.fail({
                        title : "验证码错误或失效",
                        duration : 1000
                })
            }
        })

    }

</script>
